-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix up code so we don't crash when TS itself is emitted with let/const #50151
Conversation
case AssignmentDeclarationKind.ModuleExports: | ||
valueDeclaration ||= binaryExpression.symbol?.valueDeclaration; | ||
const valueDeclaration = kind !== AssignmentDeclarationKind.ModuleExports |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this intended to be equivalent? It doesn't look equivalent (and it isn't obviously related to let
/const
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 : This is not equivalent but clearly tests are not failing..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks equivalent to me... Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's any of the original three, it'll not be equal to the 4th one, so it picks the first branch, otherwise it's ModuleExports, so it picks the second branch. I tried to keep them in order, but maybe it'd be clearer to just not use an if, and copy the two lines to both blocks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. If it was one of the first few cases but the expression turned out to be undefined, it'll pick the second expression even if it's not ModuleExports
. That is different!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked, and in all of our test cases, if binaryExpression.left.symbol?.valueDeclaration
is undefined, binaryExpression.symbol?.valueDeclaration
is also undefined, hence why my PR doesn't fail even though the logic is different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m sure I wouldn’t have written this as a falls-through and ||=
if I could have combined the cases like you have here, but it’s disappointing the tests don’t capture that. It’s possible I was being overly defensive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm OOF but had some time in the airport, changed it so it's semantically equivalent to be safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little worried about someone adding a case and missing the exception, but I agree that it looks equivalent now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The alternative is to just use var, if you all find that preferable.
@@ -1363,6 +1363,11 @@ namespace ts { | |||
onUnRecoverableConfigFileDiagnostic: noop, | |||
}; | |||
|
|||
// The call to isProgramUptoDate below may refer back to documentRegistryBucketKey; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's scary, but I don't see a better way around it. @sheetalkamat might.
Either way, thanks for the comment!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like its needed only for config file's json and we currently dont use that since we implement getParsedCommandLine
on project.. But yeah this change looks good
I know this is approved (so people must be happy enough with it), but would it be preferred for this to be Happy to do it either way. |
Please don't use |
Alternative to #50141 split out from #50022 where I was performance testing the cost of let/const.